var actbill = require('../../model/order_comment')
Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    proid: {
      type: Number,
      default: 0
    },
    customTitStyle: String,
    customConStyle: String,
    titleColor: String,
    valueColor: String,
    textColor: String,
    starColor: {
      type: String,
      value: "#FF9D1A"
    },
    timeColor: String,
    nameColor: String,
  },

  observers: {
    'proid': function (val) {
      if (val != 0) {

        var app = getApp()
        if (app.globalData && app.globalData.Custom) {

          var updatepara = {}
          updatepara["Custom"] = app.globalData.Custom
          updatepara["CustomBar"] = app.globalData.CustomBar
          this.setData(updatepara)
        }


        this.getpagelist(1, {})
      }


      // 使用 setData 设置 this.data.some.subfield 时触发
      // （除此以外，使用 setData 设置 this.data.some 也会触发）
      //  subfield === this.data.some.subfield
    },
  },
  ready: function () {


  },
  /**
   * 组件的初始数据
   */
  data: {
    evanav: [{
        name: "全部",
        num: "0"
      },
      {
        name: "好评",
        num: "0"
      },
      {
        name: "差评",
        num: "0"
      },
      {
        name: "中评",
        num: "0"
      },
      {
        name: "有图",
        num: "0"
      },
    ],
    evaindex: 0,
    triggeredsstatus: true,
    evalistshow: false,
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 初始化
    init: function (proid) {
      this.setData({
        proid: proid,
        evalistshow: true,
      })
      this.getpagelist(1)

    },
    changeevalistshow() {
      this.setData({
        evalistshow: !this.data.evalistshow
      })
    },
    getpagelist(rest, strwhere) {
      var that = this
      if (rest == 1) {
        if (!strwhere) {
          strwhere = {};
        }
        strwhere["proid"] = that.data.proid
        that.setData({
          modellist: []
        });
      }

      actbill.offset(that, rest, strwhere).then(function (result) {
        var updatemdoel = {};
        if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {
        
          var htuserinfo = result["obj"]["userinfo"]
       

          for (var a in result["obj"]["modellist"]) {
            if (result["obj"]["modellist"][a]["isreal"] == 1) {
              result["obj"]["modellist"][a]["user"] = htuserinfo[result["obj"]["modellist"][a]["uid"]]
            }
            if (result["obj"]["modellist"][a]["imglist"]) {

              result["obj"]["modellist"][a]["imglist"] = result["obj"]["modellist"][a]["imglist"].split(",")
            } else {
              result["obj"]["modellist"][a]["imglist"] = [];
            }
          }


          if (rest == 1) {
            updatemdoel["modellist"] = result["obj"]["modellist"];
          } else {
            if (result["obj"]["modellist"].length > 0) {
              updatemdoel["modellist"] = that.data.modellist.concat(result["obj"]["modellist"]);
            }
          }
        }
        if (rest == 1) {
          setTimeout(function () {
            that.setData({
              triggeredsstatus: false
            })
          }, 1000)
        }
        console.log("updatemdoel")
        console.log(updatemdoel)
        that.setData(updatemdoel);
      });
    },
    bingrefresh() {
      console.log("刷新事件")
      this.getpagelist(1)
      // this.setData({triggeredsstatus:false})

    },
    onscrollBottom() {

      console.log("触底事件")

      this.getpagelist(-1)
    }
    //   navchange:function(e){
    //     var that=this;
    //    var strwhere={proid:this.data.options.id}
    //     if(e.currentTarget.dataset.id){
    //      strwhere['id']=e.currentTarget.dataset.id
    //     }else{
    //      strwhere['labelid']=e.currentTarget.dataset.labelid
    //     }
    //     this.setData({
    //      evaindex:e.currentTarget.dataset.index
    //     })
    //    that.getpagelist(that,1,strwhere)
    //  },
  }
})